local skel = fk.CreateSkill{--定义
  name = "knu__shijing",
  tags = { Skill.Hidden },
}

Fk:loadTranslationTable{--翻译
  ["knu__shijing"] = "拭景",
  [":knu__shijing"] = "隐匿。当你登场时，你对当前回合角色造成1点冰冻伤害，本回合的判定阶段改为出牌阶段。",
  ["@@knu__shijing-turn"] = "拭景",

  ["$knu__shijing1"] = "汝大逆不道，当死无赦！",
  ["$knu__shijing2"] = "司马当兴，其兴在吾。",
}

local U = require "packages/utility/utility"

skel:addEffect(U.GeneralAppeared, {
  can_refresh = function(self, event, target, player, data)
    return target == player and player:hasSkill(skel.name, true)
  end,
  on_refresh = function (self, event, target, player, data)
    player:broadcastSkillInvoke(skel.name)
    player.room:notifySkillInvoked(player, skel.name)
    local room = player.room
    local turn_event = room.logic:getCurrentEvent():findParent(GameEvent.Turn)
    if turn_event == nil then--自己回合的破隐匿是回合外，所以返回自己
      target = player
    else
      target = turn_event.data.who--当前回合角色
    end
    if target.dead then return end
    player.room:damage({
      from = player,
      to = target,
      damage = 1,
      damageType = fk.IceDamage,
      skillName = skel.name,
    })
    player.room:setPlayerMark(target, "@@knu__shijing-turn", 1)
  end,
})


skel:addEffect(fk.EventPhaseChanging, {
  can_refresh = function(self, event, target, player, data)
    return player:hasSkill(skel.name) and data.phase == target.Judge and target:getMark("@@knu__shijing-turn") > 0
  end,
  on_refresh = function(self, event, target, player, data)
    player.room:sendLog{
      type = "本回合的判定阶段被改为出牌阶段",
    }
    data.phase = target.Play
    player.room:setPlayerMark(target, "@@knu__shijing-turn", 0)
  end,
})


return skel